﻿using UnityEditor;
using UnityEngine;

namespace EditorExtension
{
    public class AssetPostprocessorExample : AssetPostprocessor
    {
        // 导入贴图前的处理
        private void OnPreprocessTexture()
        {
            Debug.Log($"OnPreprocessTexture：{this.assetPath}");
            
            // 转成精灵
            TextureImporter importer = this.assetImporter as TextureImporter;
            importer.textureType = TextureImporterType.Sprite;
            importer.maxTextureSize = 512;
            importer.mipmapEnabled = false;
        }
        
        // 导入贴图后的处理
        private void OnPostprocessTexture(Texture2D texture)
        {
            Debug.Log($"OnPostprocessTexture: {texture.name}");
        }
    }
}